﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace Api.Common
{
    public enum DeviceType
    {
        android = 0,
        ios = 1,
        all = 2,
        unknow = 3,
    }

    public class DeviceHelper
    {
        public static DeviceType JudgeDevice()
        {
            DeviceType deviceType = DeviceType.unknow;
            var userAgent = HttpContext.Current.Request.UserAgent.ToLower();
            if (userAgent.Contains("iphone") ||
                userAgent.Contains("ipod") ||
                userAgent.Contains("ipad"))
            {
                deviceType = DeviceType.ios;
            }

            if (userAgent.Contains("android"))
            {
                deviceType = DeviceType.android;
            }
            deviceType = DeviceType.unknow;

            return deviceType;
        }
    }
}
